package ${package}.controller;

import com.alibaba.fastjson.JSON;
import ${package}.dto.${className}Dto;
import ${package}.service.${className}Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
  *${tableComment}Controller
  *@author zhuhg
  *@date 2020/05/21 19:43:42
  */
@Controller
@RequestMapping(value = {"${apiProject}/v1/${changeClassName}/"}, produces = {"application/json;charset=utf-8"})
public class ${className}Controller {
    private static final Logger logger = LoggerFactory.getLogger(${className}Controller.class);

    @Autowired
    private ${className}Service ${changeClassName}Service;

    @GetMapping(value = {"/select${className}List"}, produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public String select${className}List( ${className}Dto dto) {
        logger.info("查询 ${tableComment}数据列表 参数 -> {}" , JSON.toJSONString(dto));

        // 查询结果返回前端
        return ${changeClassName}Service.select${className}List(dto);
    }

    @PostMapping(value = {"/update${className}ById"}, produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public String update${className}ById(${className}Dto dto) {
        logger.info("根据 参数id 更新${tableComment}参数 -> {}" , JSON.toJSONString(dto));

        String json = ${changeClassName}Service.update${className}ById(dto);
        return json;
    }

    @PostMapping(value = {"/save${className}Dto"}, produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public String save${className}Dto( ${className}Dto dto) {
        logger.info("根据 参数${className}Dto 新增${tableComment}参数 -> {}" , JSON.toJSONString(dto));

        String json = ${changeClassName}Service.save${className}Dto(dto);
        return json;
    }

    @GetMapping(value = {"/select${className}ById"}, produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public String select${className}ById(${className}Dto dto) {
        logger.info("根据 参数id 查询${tableComment}参数 -> {}" , JSON.toJSONString(dto));

        String json = ${changeClassName}Service.select${className}ById(dto);
        return json;
    }
    
    @GetMapping(value = {"/cancel${className}ById"}, produces = {"application/json;charset=utf-8"})
    @ResponseBody
    public String cancel${className}ById(${className}Dto dto) {
        logger.info("根据 参数id 更新${tableComment}参数 -> {}" , JSON.toJSONString(dto));
        String json = ${changeClassName}Service.cancel${className}ById(dto);
        return json;
    }
}